#include "Headers.h"

namespace OgreUnified
{
	
		const int AxisTextSize=32;

        static Ogre::String axisText[3] = 
        {
                Ogre::String("X"),
                Ogre::String("Y"),
                Ogre::String("Z")
        };

	class AxisRenderable : public Ogre::Renderable
	{
	private:
		bool mCastShadows;
		int mPrevAxisGizmoSelAxis;
		Camera* mCamera;
		Viewport* mViewport;
		int m_max_line_count;
		int m_line_count;
		//0141173082
		Real mLength;
		Real mProjectDistance;
		bool m_local;

		RenderOperation mRenderOp;
		Real m_radius;
		Ogre::AxisAlignedBox mBox;

		void* m_locked_data;
		HardwareVertexBufferSharedPtr m_locked_buffer;

	public:
        AxisRenderable(int lineCount, Ogre::Camera* camera, Ogre::Viewport* viewport);
        ~AxisRenderable();

		void getWorldTransforms(Ogre::Matrix4* xform) const;
        const Quaternion& AxisRenderable::getWorldOrientation(void) const;
        const Vector3& AxisRenderable::getWorldPosition(void) const;
        
		void setLocal(bool local);
        bool getLocal();

        void lock();
        void unlock();
        void drawLine(const Ogre::Vector3& v1, const Ogre::Vector3& v2, const Ogre::ColourValue& c1, const Ogre::ColourValue& c2, unsigned int lineCount);
        void clear();
        Real getSquaredViewDepth(const Ogre::Camera* cam) const;
        inline Real intersect(Ogre::Plane* plane, const Ogre::Vector3& p1, const Ogre::Vector3& p2);
        inline Vector3 interpolate(const Ogre::Vector3& from, const Ogre::Vector3& to, const Ogre::Real factor);
        void calcAxisInfo(Ogre::Vector3& pos, int length);
        void renderAxisText();
        bool IsOK();
        void renderAxis();
        bool collideAxis(Ogre::Ray& ray);
        void _updateRenderQueue(Ogre::RenderQueue* queue);
        void createGuiElements(void);
        void destroyElements();
        void showElement(bool visible);
	};
}